# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-prime
_gemname=prime
# Keep version in sync with "Bundled gems" (https://stdgems.org) for the
# packaged Ruby version.
pkgver=0.1.2
pkgrel=2
pkgdesc="Prime numbers and factorization library"
url="https://github.com/ruby/prime"
arch="noarch"
license="BSD-2-Clause AND Ruby"
depends="ruby"
checkdepends="ruby-rake ruby-test-unit"
makedepends="ruby-rdoc"
subpackages="$pkgname-doc"
source="https://github.com/ruby/prime/archive/v$pkgver/$_gemname-$pkgver.tar.gz
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

prepare() {
	default_prepare
	sed -i '/require .bundler/d' Rakefile
}

build() {
	gem build $_gemname.gemspec
}

check() {
	rake test
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	gem install \
		--local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--document ri \
		--verbose \
		$_gemname

	# Remove unnessecary files
	cd "$gemdir"
	rm -rf build_info cache extensions plugins
}

doc() {
	pkgdesc="$pkgdesc (ri docs)"

	amove "$(ruby -e 'puts Gem.default_dir')"/doc
}

sha512sums="
a766426884d6b3cd7a586676799db146974ec9a4a7c30ca53b5f279ad55ee9960c9b5bb26988cb66253b4fe974f9b5087f48ef5b216772464d03b8ed78a817d6  prime-0.1.2.tar.gz
ea60d064edd9247a0a1450d9e43385cd8fc84dfcb610bd4ab174fd104727eb8066b4ad8439b9b33a715aa93890a2b0a06127d58912752919aecbc2950e419a3e  gemspec.patch
"
